﻿/* Copyright 2012 Sannel Software, L.L.C.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace Sannel.Calculate
{
	public static class StringHelpers
	{
#if CODE_ANALYSIS
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Whitespace")]
#endif
#if NET3_5 || NET4_0 || NET4_5 || WINDOWS_PHONE
		public static bool IsNullOrWhitespace(this String str)
#else

		public static bool IsNullOrWhitespace(String argument)
#endif
		{
#if NET4_0 || NET4_5
			return String.IsNullOrWhiteSpace(argument);
#else
			if (String.IsNullOrEmpty(argument))
			{
				return true;
			}

			var trimed = argument.Trim();
			return String.Compare(trimed, String.Empty, StringComparison.Ordinal) == 0;
#endif
		}
	}
}
